#include"subsetsum.h"


int subsetnumEqual(int * setA,int sizeA,int kval,unsigned int code){

    int sum = 0;
    int index = 0;
    unsigned int origcode = code;
    while((index < sizeA) && (code > 0)){

        if(code % 2 == 1){

            sum += setA[index];
        }
        index++;
        // -右移一位
        code = code >> 1;
    }
    // -相等才是解
    if(sum == kval){

        printf("equal : sum = %d, code = %X.\n",sum,origcode);
        return 1;
    }
    return 0;
}